#include <stdint.h>
#include "samples.h"

#define BLOCK_LENGTH 4 //Nb

typedef enum {KEY_128 = 0,KEY_192 = 1,KEY_256 = 2} KEY_TYPE;

extern const int _KEY_LENGTHS[3]; //Nk
extern const int _KEY_ROUNDS[3]; //Nr
extern const uint32_t Rcon[11];

#define KEY_LENGTH(l) _KEY_LENGTHS[l]
#define KEY_BYTES(l) KEY_LENGTH(l)<<2
#define ROUNDS(l) _KEY_ROUNDS[l]

typedef struct
{
	uint8_t* key_val;
	uint32_t* key_expanded;
	uint32_t* key_expanded_inv;
	KEY_TYPE type;
	int length;
	int rounds;
	int expanded_length;
}
Key;

Key* new_key(KEY_TYPE type, uint8_t* key_val);
Key* new_key_dec(KEY_TYPE type, uint8_t* key_val);
void aes_encrypt(uint8_t *input, Key *key);
void aes_decrypt(uint8_t *input, Key *key);
void aes_decrypt_equiv(uint8_t *input, Key *key);
inline uint32_t RotWord(uint32_t in);
